import { createStore } from 'vuex'

//vuex数据缓存插件
import createPersistedState from "vuex-persistedstate"

//导入考试模块
import exam from './exam/exam'
import user from './user/user'

export default createStore({
  state: {
  },
  getters: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    exam,
    user,
  },
  //vuex的数据缓存
  plugins: [
    createPersistedState({
      storage: window.sessionStorage,//默认存储在localStorage中
      reducer(state) {
        return {
          exam: state.exam,
          user: state.user,
        }
      }
    }),
  ]
})
